package com.fancy.learncenter.net;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.fancy.learncenter.bean.BaseBean;
import com.fancy.learncenter.bean.BookStoreDataBean;
import com.fancy.learncenter.common.Constant;
import com.fancy.learncenter.utils.FileUtils;
import com.fancy.learncenter.utils.LogUtil;
import com.fancy.learncenter.utils.NetUtil;
import com.fancy.learncenter.utils.SPUtils;
import com.fancy.learncenter.utils.Utils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Hyy on 2016/9/29.
 */
public class HttpMehtod {
    private static final int DEFAULT_TIMEOUT = 5;

    private Retrofit retrofit;
    private Retrofit retrofitMall;
    private Retrofit retrofitServerFFlibray;
    //    private Retrofit retrofitJunYuLocal; //俊宇本地
//    private Retrofit retrofitShouCaiLocal; //首才本地
    private static HttpMehtod instance;

    //构造方法私有
    private HttpMehtod() {

        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String message) {
                try {
//                    String text = URLDecoder.decode(message, "utf-8");
                    LogUtil.MyLog("responseBodyResponse", "请求完成：" + message);

                } catch (Exception e) {

                }
            }
        });
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        //手动创建一个OkHttpClient并设置超时时间
        OkHttpClient.Builder builder = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor())
                .addInterceptor(httpLoggingInterceptor);

        builder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);

        retrofit = new Retrofit.Builder()
                .client(builder.build())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(Constant.BASE_URL)
                .build();

        retrofitMall = new Retrofit.Builder()
                .client(builder.build())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(Constant.MALL_SERVICE_URL)
                .build();

        OkHttpClient.Builder builder1 = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor2());

        retrofitServerFFlibray = new Retrofit.Builder()
                .client(builder1.build())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(Constant.BUSINESS_SERVICE_URL)
                .build();

    }

    //获取单例
    public static HttpMehtod getInstance() {
        if (instance == null) {
            instance = new HttpMehtod();
        }
        return instance;
    }

    /**
     * 教辅平台 -- 提交答案
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCommitHomeAnser(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.commitHomeWorkAnswer(getBody(map)).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取书店所有数据
     *
     * @param subscriber
     */
    public void getHomeBookStore(CustomNetSubscriber subscriber) {
        ApiService testService = retrofitMall.create(ApiService.class);
        testService
                .getHomeBookStore()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * NGKBanner接口
     *
     * @param subscriber
     */

    public void getNGKBanner(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getNGKBanner()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取支付订单信息
     * <p>
     * <p>
     * orderNo		Long	订单号
     * payChannel	String	支付渠道:支付宝  alipay 微信 wx
     *
     * @param subscriber
     */

    public void getPayData(Map map, CustomNetSubscriber subscriber) {

        ApiService testService = retrofit.create(ApiService.class);

        testService
                .getPayData(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void urgeStudentHomework(Map map, CustomNetSubscriber subscriber) {

        ApiService testService = retrofit.create(ApiService.class);

        testService
                .urgeStudentHomework(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取版本信息
     * <p>
     * mobileVersion	是	string	当前版本号
     * appIdentify	是	string	app标识(flc)
     * platform	是	intege	平台(1-Android 2-iOS 3-PC)
     * <p>
     *
     * @param subscriber
     */

    public void getAPPVersion(Map map, CustomNetSubscriber subscriber) {

        ApiService testService = retrofit.create(ApiService.class);

        testService
                .getAPPVersion(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 秀场Banner接口
     * id	    是	Integer	类目id    秀场首页ID 为 0
     * hasTag	是	Integer	true or false  秀场 首页位true 其他为false
     *
     * @param subscriber
     */

    public void getShowBanner(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getShowBanner(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 参数名称	是否必传	类型	取值说明
     * id	    是	        Integer	媒体资源id
     * type	     是	        Integer	媒体资源类型，类目接口中有该字段，1 类目 2 标签
     * curPage	  否	   Integer	当前页
     * pageSize	 否	       nteger	当前页记录数
     *
     * @param map
     * @param subscriber
     */
    public void getShowCategory(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getShowCategoryListData(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 获取评论
     * entityId	是	Long	评论绑定实体的id
     * type	是	Integer	绑定实体的类型0-资讯评论 1-活动评论 2-频道视频评论 3-秀场评论
     * curPage	否	Integer	当前页
     * pageSize	否	Integer	每页条目数
     * sortType	否	Integer	不传为默认(最新),1-最热
     *
     * @param map
     * @param subscriber
     */
    public void getDiscuss(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getDiscuss(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取二维码
     *
     * @param subscriber
     */
    public void getQRCode(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getQRCode()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取学堂首页
     *
     * @param subscriber
     */
    public void getSchool(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getSchool()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 秀场视屏和音频接口
     * <p>
     * 参数名称	是否必传	类型	取值说明
     * type	    是	        String	audio or video
     * curPage	是	        Integer	当前页
     * pageSize	是	        Integer	当前页记录数
     *
     * @param map
     * @param subscriber
     */
    public void getShowListData(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getShowListData(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * NGK List 接口
     * <p>
     * curPage
     * pageSize
     *
     * @param subscriber
     */

    public void getNGKListData(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getNGKList(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * schoolId	否	Long	学校id(视频页增加查看数时id=0)
     * entityId	是	Long	咨询id/活动id/视频id(视频id)
     * type	是	Integer	    3秀场音视频查看数     4文章(咨询)查看数
     *
     * @param map
     * @param subscriber
     */
    public void addPV(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .addPv(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * entityId	是	Long	评论绑定实体的id
     * type	    是	Integer	绑定实体的类型0-资讯评论 1-活动评论 2-频道视频评论 3-秀场评论
     * content	是	String	评论内容
     *
     * @param map
     * @param subscriber
     */
    public void addComment(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .addComment(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * entityId	是	Long	实体id(秀场的id)
     * type	是	Integer	点赞类型0-评论点赞 1-活动点赞 2-频道点赞 3-秀场点赞
     *
     * @param map
     * @param subscriber
     */
    public void getPraiseNum(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getPraiseNum(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * entityId	是	Long	实体id(秀场的id)
     * type	是	Integer	点赞类型0-评论点赞 1-活动点赞 2-频道点赞 3-秀场点赞
     *
     * @param map
     * @param subscriber
     */
    public void addPraiseNum(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .addPraiseNum(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 改变消息阅读状态 未读-->已读
     * <p>
     * messageId	是	Long	信息id
     *
     * @param map
     * @param subscriber
     */
    public void changeMsgState(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .changeReadState(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * NGK List 接口
     * <p>
     * curPage	否	Integer	当前页码
     * pageSize	否	Integer	每页显示条目数
     *
     * @param subscriber
     */

    public void getOnlineRecorderAudio(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getOnlineRecorderAudio(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 获取学堂详情
     *
     * @param lessonType 课程详情的id
     * @param subscriber
     */
    public void getCourseData(int lessonType, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getCourseData(lessonType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取学堂课程
     * <p>
     * schoolId	否	Long	学校的id
     * lessonId	是	Long	课程的id
     *
     * @param map
     * @param subscriber
     */
    public void getALLLesson(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getAllLesson(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

//    /**
//     * @param lessonSchoolDetailId 课程详情的id
//     * @param subscriber
//     */
//    public void getCourseListData(long lessonSchoolDetailId, CustomNetSubscriber subscriber) {
//        ApiService testService = retrofit.create(ApiService.class);
//        testService
//                .getCourseData(lessonSchoolDetailId)
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(subscriber);
//    }

    /**
     * 获取我的绑定学校信息
     *
     * @param subscriber
     */
    public void getMySchoolDeatail(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getMySchoolDeatail()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取所有绑定城市省份和城市
     *
     * @param subscriber
     */
    public void getAllCity(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getAllCity()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取相应的市或者区下面的学校列表(学校类型也是筛选条件)
     * <p>
     * 参数名称	是否必传	类型	取值说明
     * cityId	是	Long	城市id
     * areaId	否	Long	区id
     * types	否	String	学校类型:ngl:1,3 学习中心:2,3 全部:不传
     * curPage	否	Integer	当前页
     * pageSize	否	Integer	页面最大数
     *
     * @param map
     * @param subscriber
     */
    public void getAllSchool(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getAllSchool(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * @param schoolId   学校ID
     * @param subscriber
     */
    public void bindSchool(long schoolId, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .bindSchool(schoolId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * @param schoolId   学校ID
     * @param subscriber
     */
    public void deBindSchool(long schoolId, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .deBindSchool(schoolId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取音视频详情
     *
     * @param subscriber
     */
    public void getMedioDetail(int id, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getMedioDetail(id)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 上传录音
     * file	               	filePath	音频或视频源文件
     * showResourceName		String	资源名
     * recordImg		    String	封面图
     * intro		        String	简介
     * type	            	Integer	3
     * customerId	     	Long	当前用户id
     *
     * @param subscriber
     */

    public void upAudio(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);

//        //构建要上传的文件
//        File file = new File((String) map.get("filePath"));
//        RequestBody photoRequestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);


        Map<String, RequestBody> partMap = new HashMap<>();
        //构建要上传的文件
        File file = new File((String) map.get("filePath"));
        RequestBody photoRequestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        partMap.put("file\"; filename=\"" + file.getName() + "", photoRequestBody);

        testService
                .upAudio(partMap, map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 上传图片
     *
     * @param filePath   图片地址
     * @param subscriber 回调接口
     */

    public void upHeaderIcon(String filePath, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        Map<String, RequestBody> partMap = new HashMap<>();
        //构建要上传的文件
        File file = new File(filePath);
        RequestBody photoRequestBody = RequestBody.create(MediaType.parse("image/*"), file);
        partMap.put("file\"; filename=\"" + file.getName() + "", photoRequestBody);

        testService
                .upHeaderIcon(partMap)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void uploadClassHeaderImage(String filePath, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        Map<String, RequestBody> partMap = new HashMap<>();
        //构建要上传的文件
        File file = new File(filePath);
        RequestBody photoRequestBody = RequestBody.create(MediaType.parse("image/*"), file);
        partMap.put("file\"; filename=\"" + file.getName() + System.currentTimeMillis() + "", photoRequestBody);

        testService
                .uploadClassHeaderImage(partMap)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 修改昵称
     *
     * @param name       昵称
     * @param subscriber
     */
    public void setName(String name, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .setName(name)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取我的收藏
     *
     * @param customerId 用户id,在loginUser中
     * @param type       收藏类型    0-活动1-商品 2-文章
     * @param subscriber
     */
    public void getCollection(long customerId, int type, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getMyCollection(customerId, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取消息
     *
     * @param subscriber
     */

    public void getAllMessage(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getAllMessage()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取未读消息总数
     *
     * @param subscriber
     */
    public void getUnMessage(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getUnMessage()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取token jession
     *
     * @param subscriber
     */

    public void getToken(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取每日听说列表
     * <p>
     * <p>
     * type  每日 "1" 拓展 2 绘本 3
     *
     * @param subscriber
     */

    public void submitWork(Map<String, RequestBody> params, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
//        Map<String, RequestBody> partMap = new HashMap<>();
//        //构建要上传的文件
//        File file = new File((String) map.get("filePath"));
//        RequestBody photoRequestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
//        partMap.put("file\"; filename=\"" + file.getName() + "", photoRequestBody);

        testService
                .submitWork(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 登录接口
     *
     * @param map
     * @param subscriber
     */
    public void login(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);

        testService
                .login(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 登出
     *
     * @param subscriber
     */
    public void loginOut(CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .loginOut()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    public void regist(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .regist(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取验证码  没有注册过的用户
     * <p>
     * mobile  需要注册的手机号
     *
     * @param mobile
     * @param subscriber
     */

    public void getRegsiterCode(String mobile, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getRegsiterCode(mobile)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取分享信息
     * <p>
     * entityId	是	Long	秀场音频或者视频的实体id
     * shareType	是	Integer	分享的实体类型，暂定秀场的音频和视频为1
     *
     * @param subscriber
     */

    public void getShareData(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getShareData(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取验证码  已经注册过的手机号
     *
     * @param mobile     找回密码的手机号
     * @param subscriber
     */

    public void getPWDCode(String mobile, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .getPWDCode(mobile)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 重置密码
     * 需要加密      Token + 新密码   进行RSA加密
     * vCode            验证码
     * newPassword      新密码
     * mobile           手机号
     *
     * @param map
     * @param subscriber
     */
    public void findPWD(Map map, CustomNetSubscriber subscriber) {
        ApiService testService = retrofit.create(ApiService.class);
        testService
                .findPWD(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 我的客服
     *
     * @param subscriber
     */
    public void getServiceInfo(CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getService().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 - 根据id 获取作业包
     *
     * @param map
     * @param subscriber
     */
    public void cartoonDownloadHomeWorkById(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.downLoadHomeWorkNyId(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 教辅平台-作业列表
     *
     * @param subscriber
     */
    public void cartoonListWork(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listHomePackage(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 教辅平台-做作业进度
     *
     * @param map
     * @param subscriber
     */
    public void cartoonStaticsWork(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listHomeSstatics(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 后期班级ID
     *
     * @param subscriber
     */
    public void getClassId(CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getClassId()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 作业报告展示list
     *
     * @param map
     * @param subscriber
     */
    public void cartoonStaticsReport(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listStaticsReport(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台，未订正
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCountUnCorrect(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.countUnCorrect(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void deleteClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.deleteClass(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void delTeacherFromClas(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.delTeacherFromClas(map).





                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void checkClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.checkClass(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void checkCreateClassNum(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.checkCreateClassNum(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 已订正 未订正
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCorrectState(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listCorrectState(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 教辅平台 错题类目 根据id
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListConstructId(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listConstructId(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 加入班级
     *
     * @param map
     * @param subscriber
     */
    public void cartoonJoinClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.joinClassForStudent(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 -- 提交答案
     *
     * @param map
     * @param subscriber
     */

    public void cartoonCommitHomeAnsers(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.commitHomeWorkAnswer(getBody(map)).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 -- 提交答案
     *
     * @param map
     * @param subscriber
     */
    public void cartoonlistStudentHomeworkAnswer(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listStudentHomeworkAnswer(getBody(map)).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void assigStudentHomework(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.assigStudentHomework(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void urgeStudentSpeak(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.urgeStudentSpeak(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 教辅平台 -- 完成作业
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCompleteHomeWorks(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.completeHomework(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 错题分类-错题类目
     *
     * @param subscriber
     */
    public void cartoonListErrorKinds(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listErrorStatics(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 --作业报告 获取客观题答案
     *
     * @param map
     * @param subscriber
     */
    public void cartoonGetHomeAnswer(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getHomeAnswer(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 --完成作业 获取单元列表
     *
     * @param map
     * @param subscriber
     */
    public void cartoonGetUnitList(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getUnitList(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 --获取班级列表
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListOfClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listClassOfStudent(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 --获取单元提包
     *
     * @param map
     * @param subscriber
     */
    public void speakPackageDetail(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.speakPackageDetail(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取首次作业包的数量
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCountHomeWorks(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.countDoneHomeworkDetail(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取首次作业包的数量
     *
     * @param map
     * @param subscriber
     */
    public void checkQuestionIsDone(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.checkQuestionIsDone(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 萝卜排行榜
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListRadishRank(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listRadishRank(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getRadishRank(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getRadishRank(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 教辅平台 --获取主观题列表
     * <p>
     * type 主观题包类型 1-每日 2-拓展 3-绘本
     * <p>
     * classId  班级id
     *
     * @param map
     * @param subscriber
     */
    public void listSpeakPackage(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listSpeakPackage(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教辅平台 --获取主观题已发布列表
     * <p>
     * type 主观题包类型 1-每日 2-拓展 3-绘本
     * <p>
     * classId  班级id
     *
     * @param map
     * @param subscriber
     */
    public void releaseSpeaking(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.releaseSpeaking(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取已发布详情
     *
     * @param map
     * @param subscriber
     */
    public void releaseDetail(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.releaseDetail(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 错题中心-错题分类，未订正 提交接口
     *
     * @param map
     * @param subscriber
     */
    public void cartoonCorrectErrorQuestion(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.correctErrorQuestion(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 防止本地的作业题包被删了，根据ids请求接口获取错题列表
     *
     * @param map
     * @param subscriber
     */
    public void cartoonDownLoadHomeworkByQids(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.downLoadHomeworkByQids(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 错题中心-- 单元列表
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListHomeworkError(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listHomeworkError(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取班级列表
     * className
     *
     * @param subscriber
     */
    public void getSchoolGroup(CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getSchoolGroup()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取教材列表
     * getListLessonOfSchool
     *
     * @param map
     * @param subscriber
     */
    public void getListLessonOfSchool(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getListLessonOfSchool(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取班级列表
     * getListLessonOfSchool
     *
     * @param map
     * @param subscriber
     */
    public void getListClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getListClass(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取作业列表
     * map
     *
     * @param map
     * @param subscriber
     */
    public void getListWork(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getListWork(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void everyDayPreView(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.everyDayPreView(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 创建班级
     * classId
     * schoolId
     * className
     * classImgurl
     * lessonId
     * startTime
     * endTime
     * studentCount
     * classDesc
     *
     * @param map
     * @param subscriber
     */
    public void creatClass(RequestBody map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.creatClass(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getTeacherList(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getTeacherList(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void getStudentList(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.getStudentList(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void addTeacher(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.addTeacher(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void queryTeacher(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.queryTeacher(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void addStudent(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.addStudent(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void editStudent(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.editStudent(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void removeStudent(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.removeStudent(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void swapIdentify(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.swapIdentify(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public void queryStudent(Map map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.queryStudent(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 获取班级下属的作业包
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListHomeworkByClass(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listHomeworkByClass(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端-报告详情
     *
     * @param map
     * @param subscriber
     */
    public void cartoonListStudentHomework(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.cartoonListStudentHomework(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端- 返回作业的统计数据（选择作业包预览）
     *
     * @param map
     * @return
     */
    public void cartoonListHomeworkStatistic(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.cartoonListHomeworkStatistic(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 布置作业
     *
     * @param map
     * @param subscriber
     */
    public void cartoonAssignHomework(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.cartoonAssignHomework(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端--下载作业包
     *
     * @param map
     * @param subscriber
     */
    public void cartoonTeacherDownLoadHomeworkById(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.cartoonTeacherDownLoadHomeworkById(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端-- 每日跟读
     *
     * @param map
     * @param subscriber
     */
    public void listStudentSpeak(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listStudentSpeak(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端-- 每日跟读 详情
     *
     * @param map
     * @param subscriber
     */
    public void listStudentSpeakDoneDetail(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.listStudentSpeakDoneDetail(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 教师端-- 学生作业，统计报告
     * classId
     * statisticType  统计类型 1-当周 2-累计
     *
     * @param map
     * @param subscriber
     */
    public void reportHomeWork(Map<String, Object> map, CustomNetSubscriber subscriber) {
        ApiService service = retrofit.create(ApiService.class);
        service.reportHomeWork(map).
                subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    private RequestBody getBody(Map value) {

//        JSONObject jsonObject = new JSONObject(value);

//        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(value);
//        String str = jsonObject.toString();
        Gson gson = new Gson(); //防止为空
        String str = gson.toJson(value);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json;charset=utf-8"), str);
        return body;
    }


    /**
     * 非凡学习金牌老师
     */

    public void getGoldLectureList(Map<String, String> valueData, Subscriber subscriber) {

        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        com.google.gson.JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }
        String sign = FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY);
        service.getGoldLectureList(sign, "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }


    public void getAppConfig(Map<String, String> valueData, Subscriber subscriber) {

        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        com.google.gson.JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }
        String sign = FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY);
        service.getAppConfig(sign, "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    /**
     * 金牌老师个人信息
     *
     * @param valueData
     * @param subscriber
     */
    public void getGoldLectureInfo(Map<String, String> valueData, Subscriber subscriber) {

        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }

        service.getUserData(FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY), "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }

    /**
     * 获取金牌老师故事列表
     *
     * @param valueData
     * @param subscriber
     */
    public void getGoldLecutreStory(Map<String, String> valueData, Subscriber subscriber) {

        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }

        service.getListRecommend(FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY), "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }

    /**
     * 添加金牌老师播放次数
     *
     * @param valueData
     * @param subscriber
     */
    public void addStoryRadioSetPlayCount(Map<String, String> valueData, Subscriber subscriber) {

        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }

        service.addStoryRadioSetPlayCount(FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY), "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

    }


    /**
     * 获取系统时间
     *
     * @param subscriber
     * @param valueData
     */
    public void getFFlibrarySystemTime(Subscriber subscriber, Map<String, String> valueData) {
        ApiService service = retrofitServerFFlibray.create(ApiService.class);
        com.google.gson.JsonObject jsonObject = FfLibraryNet.generateRequestJson(valueData);
        if (valueData.containsKey("time")) {
            valueData.remove("time");
        }

        service.getSystemTime(FfLibraryNet.getRequestSign(jsonObject, Constant.REQUEST_KEY), "1.6.8", valueData)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }


    /**
     * 返回拦截
     */
    public static class LoggingInterceptor2 implements Interceptor {

        @Override
        public okhttp3.Response intercept(Chain chain) throws IOException {

            Request request = chain.request()
                    .newBuilder()
                    .addHeader("X-FANCY-APPNO", Constant.FANCY_APP_NO)
                    .addHeader("X-FANCY-APIVERSION", Constant.FANCY_API_VERSION)
                    .addHeader("X-FANCY-TIMESTAMP", String.valueOf(Utils.getCurrentTimeMillis()))
                    .addHeader("X-FANCY-USERID", "")
                    .addHeader("X-FANCY-USERTOKEN", "")
                    .addHeader("X-FANCY-PLATFORM", Constant.FANCY_API_PLATFORM)
                    .build();

            LogUtil.MyLog("responseBodyResponse", "开始请求：请求链接=" + request.url().url().toString() + "，请求头=" + request.headers().toString() + "，请求数据=" + request.toString());
            //long t1 = System.nanoTime();
            okhttp3.Response response = chain.proceed(request);

            LogUtil.MyLog("responseBodyResponse", "请求完成：" + response.toString());
            //long t2 = System.nanoTime();
            return response;
        }
    }


    /**
     * 返回拦截
     */
    public class LoggingInterceptor implements Interceptor {

        @Override
        public okhttp3.Response intercept(Chain chain) throws IOException {

            Request request = chain.request()
                    .newBuilder()
                    //添加cookie
                    .addHeader("Cookie", "JSESSIONID=" + Constant.JSESSIONID)
                    .build();

            LogUtil.MyLog("responseBodyResponse", "开始请求：请求链接=" + request.url().url().toString() + "，请求头=" + request.headers().toString() + "，请求数据=" + request.toString());
            //long t1 = System.nanoTime();
            okhttp3.Response response = chain.proceed(request);

            //long t2 = System.nanoTime();
            return response;
        }
    }


//    HttpMehtod.getInstance().getHomeBookStore(new CustomNetSubscriber(getActivity()) {
//        @Override
//        public void onNext(Response<ResponseBody> responseBodyResponse) {
//            //解析数据
//            BaseBean<BookStoreDataBean> baseBean = Utils.fromJsonObject(NetUtil.getResResult(responseBodyResponse), BookStoreDataBean.class);
//            //数据业务逻辑处理
//            CustomNetCallBack callBack = new CustomNetCallBack(baseBean);
//            callBack.setCallBack(new CustomNetCallBack.NetCallBack<BookStoreDataBean>() {
//                @Override
//                public void success(BookStoreDataBean dataBean) {
//                }
//
//                @Override
//                public void fail() {
//
//                }
//            }).dealData();
//        }
//
//        @Override
//        public void onCompleted() {
//            super.onCompleted();
//        }
//    });

}
